import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '@/pages/home/Home.vue'
import Goods from '@/pages/goods/Goods.vue'
import Detail from '@/pages/common/Detail.vue'
import Cart from '@/pages/cart/Cart.vue'
import OrderForm from '@/pages/cart/components/OrderForm.vue'
import Profile from '@/pages/profile/Profile.vue'
import Login from '@/pages/profile/components/Login.vue'
import Register from '@/pages/profile/components/Register.vue'
import AddNewAddress from '@/pages/profile/components/AddNewAddress.vue'
import ManageAddress from '@/pages/profile/components/ManageAddress.vue'
import ModifyAddress from '@/pages/profile/components/ModifyAddress.vue'
import ManageOrder from '@/pages/profile/components/ManageOrder.vue'
import OrderDetail from '@/pages/profile/components/OrderDetail.vue'

Vue.use(VueRouter)

const routes = [
  { path: '/', redirect: '/home' },
  { path: '/home', component: Home },
  { path: '/goods', component: Goods },
  { path: '/goods/:id', component: Goods },
  { path: '/detail', component: Detail },
  { path: '/cart', component: Cart },
  { path: '/cart/order', component: OrderForm },
  { path: '/profile', component: Profile },
  { path: '/addaddress', component: AddNewAddress },
  { path: '/manageaddress', component: ManageAddress },
  { path: '/modifyaddress', component: ModifyAddress },
  { path: '/manageorder', component: ManageOrder },
  { path: '/orderdetail', component: OrderDetail },
  { path: '/login', component: Login },
  { path: '/register', component: Register }
]

const router = new VueRouter({
  routes,
  // 解决路由跳转后，不显示在首行
  scrollBehavior () {
    return { x: 0, y: 0 }
  }
})

export default router
